//
//  AnnCollectionViewCell.m
//  MountEverestFM
//
//  Created by ChenNing on 15/11/2.
//  Copyright © 2015年 chenn. All rights reserved.
//

#import "AnnCollectionViewCell.h"

@interface AnnCollectionViewCell()
@property(nonatomic,strong)UILabel *nickLabel;
@end

@implementation AnnCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageViewButton = [[UIButton alloc] init];
        [self.contentView addSubview:_imageViewButton];
        
        self.nickLabel = [[UILabel alloc] init];
        self.nickLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_nickLabel];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.imageViewButton.frame = CGRectMake(0, 0, (FM_Screen_Width-FM_Screen_Pts_Width*40)/3, (FM_Screen_Width-FM_Screen_Pts_Width*40)/3);
    self.nickLabel.frame = CGRectMake(0, (FM_Screen_Width-FM_Screen_Pts_Width*40)/3+FM_Screen_Pts_Height*10, (FM_Screen_Width-FM_Screen_Pts_Width*40)/3, FM_Screen_Pts_Height*30);
}

- (void)setAnnDictionary:(NSDictionary *)annDictionary
{
    if (_annDictionary != annDictionary) {
        _annDictionary = annDictionary;
    }
    [self setAnnouncerInfo:annDictionary];
}

- (void)setAnnouncerInfo:(NSDictionary *)annDictionary
{
    NSURL *imageViewUrl = [NSURL URLWithString:[annDictionary objectForKey:@"smallLogo"]];
    [self.imageViewButton sd_setBackgroundImageWithURL:imageViewUrl forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"find_kind_btn_default@3x.png"]];
    self.nickLabel.text = [annDictionary objectForKey:@"nickname"];
}

@end
